package com.ruanda.mapper;

import com.ruanda.domain.Prod;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
* @author 亦樂
* @description 针对表【prod(商品)】的数据库操作Mapper
* @createDate 2024-09-05 16:57:58
* @Entity com.ruanda.domain.Prod
*/
public interface ProdMapper extends BaseMapper<Prod> {

    @Update("update prod set sold_num = sold_num - #{count},total_stocks = total_stocks + #{count},version = version + 1 where prod_id = #{prodId} and version = #{version} and (total_stocks + #{count})>=0")
    Integer updateProdStock(@Param("prodId") Long prodId, @Param("count") Integer count, @Param("version") Integer version);
}




